#ifndef __CE_POOL_H__
#define __CE_POOL_H__

#include "ce_core.h"

typedef struct ce_pool_data_s ce_pool_data_t;

struct ce_pool_data_s {
    ce_pool_data_t     *next;
};

typedef struct {
    ce_lock_t           lock;
    size_t              size;
    uint32_t            n;

    ce_alloc_t         *alloc;

    ce_pool_data_t     *free;
    uint32_t            nfree;
    uint32_t            nalloc;
} ce_pool_t;

ce_pool_t *ce_create_pool(size_t data_size, uint32_t n);
void ce_destroy_pool(ce_pool_t *pool);

void *ce_pool_get(ce_pool_t *pool);
void ce_pool_put(ce_pool_t *pool, void *data);

#endif
